package grape.crm.service.customercontact.impl;

import grape.crm.service.customercontact.map.CustomerContactServiceMapper;
import grape.crm.service.customercontact.param.AddCustomerContactParam;
import grape.crm.service.customercontact.po.CustomerContact;
import grape.crm.service.customercontact.mapper.CustomerContactMapper;
import grape.crm.service.customercontact.api.ICustomerContactService;
import grape.common.service.common.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 客户联系方式表 服务实现类
 * </p>
 *
 * @author yangwei
 * @since 2020-09-14
 */
@Service
public class CustomerContactServiceImpl extends BaseServiceImpl<CustomerContactMapper, CustomerContact> implements ICustomerContactService {

    @Autowired
    private CustomerContactServiceMapper customerContactServiceMapper;
    @Override
    public boolean batchAddCustomerContact(String customerId, List<AddCustomerContactParam> customerContacts) {

        List<CustomerContact> customerContactList = new ArrayList<>(customerContacts.size());
        CustomerContact customerContact = null;
        for (AddCustomerContactParam customerContactParam : customerContacts) {
            customerContact = customerContactServiceMapper.paramToPo(customerContactParam);
            customerContact.setCustomerId(customerId);
            customerContactList.add(customerContact);
        }
        // 保存联系方式
        return saveBatch(customerContactList);
    }
}
